{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "municipal-accordance",
   "metadata": {},
   "source": [
    "## 1 介绍\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "selected-grade",
   "metadata": {},
   "source": [
    "## 2 特征工程"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ambient-perth",
   "metadata": {},
   "source": [
    "### 2.0 准备阶段\n",
    "\n",
    "#### 2.0.1 导入必要的包和库"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "elementary-death",
   "metadata": {},
   "outputs": [],
   "source": [
    "from model import Model"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "harmful-layer",
   "metadata": {},
   "source": [
    "### 2.1 训练集特征"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "promising-burner",
   "metadata": {},
   "outputs": [],
   "source": [
    "model = Model('eval')\n",
    "ad_data = model.readData()\n",
    "ad_data = model.convert_data(ad_data)\n",
    "data, target = model.datafilter(ad_data)\n",
    "\n",
    "featurelist = model.getGBDTFeatureTrainOnehot(data)\n",
    "appendData = model.featureAppend(data, featurelist)\n",
    "\n",
    "np.savetxt(\"feature_onehot_only_20180321.txt\", featurelist);\n",
    "np.savetxt('GBDTTrainFeature.txt', appendData)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "accompanied-luxury",
   "metadata": {},
   "source": [
    "### 2.2 测试集特征"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "waiting-lingerie",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Run train before getTestFeature\n",
    "# This program is depended on xgbModelFinal\n",
    "# with trainModel to produce GBDT feature for testing\n",
    "\n",
    "model = Model('test')\n",
    "ad_data = model.readData()\n",
    "ad_data = model.convert_data(ad_data)\n",
    "data, target = model.datafilter(ad_data)\n",
    "featurelist = model.getGBDTFeatureTest(data)\n",
    "\n",
    "np.savetxt('GBDTTestFeature.txt', featurelist)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
